//
//  TableViewCell.m
//  IhuayuanClient
//  Created by 黄思清 on 2017/6/27.
//  Copyright © 2017年 com.ihuayuan. All rights reserved.
//

#import "MainTableViewCell.h"

@implementation MainTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.leftImage = [[UIImageView alloc]init];
        [self.contentView addSubview:self.leftImage];
        self.titleLabel = [[UILabel alloc]init];
        self.titleLabel.font = [UIFont systemFontOfSize:18];
        [self.contentView addSubview:self.titleLabel];
        self.remarkLabel = [[UILabel alloc]init];
        self.remarkLabel.font = [UIFont systemFontOfSize:13];
        self.remarkLabel.textColor = UIColors(0x666666);
        self.remarkLabel.numberOfLines = 2;
        [self.contentView addSubview:self.remarkLabel];
        self.lineView = [[UIView alloc]init];
        [self.lineView setBackgroundColor:UIColors(0x75C3CF)];
        [self.contentView addSubview:self.lineView];
        self.lineV = true;
        self.isHoilday = [[UIImageView alloc]init];
        self.isHoilday.image = [UIImage imageNamed:@"isleave_icon"];
        [self.contentView addSubview:self.isHoilday];
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    [self.leftImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(10);
        make.top.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.width.mas_equalTo(50);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftImage.mas_right).offset(5);
        make.top.mas_equalTo(5);

    }];

    [self.isHoilday mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.centerY.equalTo(self.titleLabel.mas_centerY);
         make.left.equalTo(self.titleLabel.mas_right).offset(10);
         make.width.mas_equalTo(50);
         make.height.mas_equalTo(25);
     }];

    [self.remarkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftImage.mas_right).offset(5);
        make.top.equalTo(self.titleLabel.mas_bottom).offset(5);
        make.width.mas_equalTo(KscreenW-80);
    }];

    
    if(self.lineV==false){
        [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.leftImage.mas_bottom).offset(0);
            make.left.mas_equalTo(0);
            make.width.mas_equalTo(0);
            make.height.mas_equalTo(0);
        }];
    }else{
        [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.leftImage.mas_bottom).offset(0);
            make.left.mas_equalTo(35);
            make.width.mas_equalTo(1);
            make.height.mas_equalTo(30);
        }];
    }
}


@end
